package QuanLyNhanSu;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.rmi.activation.ActivationMonitor;

import javax.swing.*;

public class frmCapNhatNhanVien extends JFrame implements ActionListener, KeyListener{

	SetControl set = new SetControl();
	
	JButton jbt_CapNhat = new JButton("Cập nhật"),
			jbt_Huy = new JButton("Hủy bỏ");
	
	JTextField 	jtf_MaNV = new JTextField(),
				jtf_HoTen = new JTextField(),
				jtf_SoDT = new JTextField(),
				jtf_Email = new JTextField(),
				jtf_NamSinh = new JTextField(),
				jtf_HSL = new JTextField(),
				jtf_HSPC = new JTextField(),
				jtf_ChucVu = new JTextField(),
				jtf_PhongBan = new JTextField();
	
	JLabel 	jlb_TieuDe = new JLabel("THÔNG TIN NHÂN VIÊN"),
			jlb_MaNV = new JLabel("Mã nhân viên:"),
			jlb_HoTen = new JLabel("Họ và tên:"),
			jlb_GioiTinh = new JLabel("Giới tính:"),
			jlb_SoDT = new JLabel("Số điện thoại:"),
			jlb_Email = new JLabel("Email:"),
			jlb_NamSinh = new JLabel("Năm sinh:"),
			jlb_HSL = new JLabel("Hệ số lương:"),
			jlb_HSPC = new JLabel("Hệ số phụ cấp:"),
			jlb_ChucVu = new JLabel("Chức vụ:"),
			jlb_PhongBan = new JLabel("Phòng ban:");
	JRadioButton jrb_Nam = new JRadioButton("Nam"),
				 jrb_Nu = new JRadioButton("Nữ");
	
	public void SetLayOut(){
		jlb_TieuDe.setForeground(new Color(0, 128, 128));
		jlb_TieuDe.setFont(new Font("Tahoma", Font.BOLD, 20));
		jlb_TieuDe.setBounds(new Rectangle(65,10,300,25));
		
		set.setFont(jlb_MaNV);set.setFont(jlb_HoTen);set.setFont(jlb_GioiTinh);set.setFont(jlb_SoDT);set.setFont(jlb_NamSinh);
		set.setFont(jlb_Email);set.setFont(jlb_HSL);set.setFont(jlb_HSPC);set.setFont(jlb_ChucVu);set.setFont(jlb_PhongBan);		
		set.setFont(jtf_MaNV);set.setFont(jtf_HoTen);set.setFont(jtf_SoDT);set.setFont(jtf_NamSinh);
		set.setFont(jtf_Email);set.setFont(jtf_HSL);set.setFont(jtf_HSPC);set.setFont(jtf_ChucVu);set.setFont(jtf_PhongBan);		
		set.setFont(jbt_CapNhat);set.setFont(jbt_Huy);
		set.setFont(jrb_Nam);set.setFont(jrb_Nu);jrb_Nam.setSelected(true);
		
		jlb_MaNV.setBounds(new Rectangle(20, 50, 120, 25)); 
		jlb_HoTen.setBounds(new Rectangle(20, 80, 120, 25)); 
		jlb_GioiTinh.setBounds(new Rectangle(20, 110, 120, 25)); 
		jlb_SoDT.setBounds(new Rectangle(20, 140, 120, 25)); 
		jlb_Email.setBounds(new Rectangle(20, 170, 120, 25)); 
		jlb_NamSinh.setBounds(new Rectangle(20, 200, 120, 25)); 
		jlb_HSL.setBounds(new Rectangle(20, 230, 120, 25)); 
		jlb_HSPC.setBounds(new Rectangle(20, 260, 120, 25)); 
		jlb_ChucVu.setBounds(new Rectangle(20, 290, 120, 25));
		jlb_PhongBan.setBounds(new Rectangle(20, 320, 120, 25)); 
		ButtonGroup btg = new ButtonGroup(); btg.add(jrb_Nam); btg.add(jrb_Nu);		
		jtf_MaNV.setBounds(new Rectangle(140, 50, 200, 25)); 
		jtf_HoTen.setBounds(new Rectangle(140, 80, 200, 25)); 
		jrb_Nam.setBounds(new Rectangle(140, 110, 60, 25)); 
		jrb_Nu.setBounds(new Rectangle(200, 110, 60, 25)); 
		jtf_SoDT.setBounds(new Rectangle(140, 140, 200, 25)); 
		jtf_Email.setBounds(new Rectangle(140, 170, 200, 25)); 
		jtf_NamSinh.setBounds(new Rectangle(140, 200, 200, 25)); 
		jtf_HSL.setBounds(new Rectangle(140, 230, 200, 25)); 
		jtf_HSPC.setBounds(new Rectangle(140, 260, 200, 25)); 
		jtf_ChucVu.setBounds(new Rectangle(140, 290, 200, 25)); 
		jtf_PhongBan.setBounds(new Rectangle(140, 320, 200, 25)); 
				
		jbt_CapNhat.setBounds(new Rectangle(90, 350, 120, 30)); 
		jbt_Huy.setBounds(new Rectangle(220, 350, 120, 30));
		
		jtf_NamSinh.setHorizontalAlignment(JTextField.RIGHT);
		jtf_HSL.setHorizontalAlignment(JTextField.RIGHT);
		jtf_HSPC.setHorizontalAlignment(JTextField.RIGHT);
		
		add(jlb_TieuDe);		
		add(jlb_MaNV);add(jlb_HoTen);add(jlb_GioiTinh);add(jlb_SoDT);add(jlb_NamSinh);
		add(jlb_Email);add(jlb_HSL);add(jlb_HSPC);add(jlb_ChucVu);add(jlb_PhongBan);		
		add(jtf_MaNV);add(jtf_HoTen);add(jrb_Nam);add(jrb_Nu);add(jtf_SoDT);add(jtf_NamSinh);
		add(jtf_Email);add(jtf_HSL);add(jtf_HSPC);add(jtf_ChucVu);add(jtf_PhongBan);		
		add(jbt_CapNhat); add(jbt_Huy);
	}
	
	public frmCapNhatNhanVien(){
		setSize(380, 430);
		setVisible(true);
		setTitle("Cập nhật thông tin nhân viên");
		setLayout(null);
		SetLayOut();
		jbt_CapNhat.addActionListener(this);
		jbt_Huy.addActionListener(this);		
		
		
		/*if(index != -1){
			System.out.println(NV.getMaNV());
			jtf_MaNV.setText(NV.getMaNV()); jtf_MaNV.setEnabled(false);
			jtf_HoTen.setText(NV.getHoTen());
			jrb_Nam.setSelected(NV.GioiTinh);
			jtf_SoDT.setText(NV.getSoDT());
			jtf_Email.setText(NV.getEmail());
			jtf_NamSinh.setText(String.valueOf(NV.getNamSinh()));
			jtf_HSL.setText(String.valueOf(NV.getHSL()));
			jtf_HSPC.setText(String.valueOf(NV.getHSPC()));
			jtf_ChucVu.setText(NV.getChucVu());
			jtf_PhongBan.setText(NV.getPhongBan());
		}*/
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new frmCapNhatNhanVien();
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		if(e.getSource() == jbt_Huy){
			int message = JOptionPane.showConfirmDialog(null, "Bạn có muốn lưu thay đổi không?", "Lưu?", JOptionPane.YES_NO_OPTION);
			if(message == JOptionPane.YES_OPTION){
				//
				System.exit(0);
			}
			else {
				System.exit(0);
			}
		}
		if(e.getSource() == jbt_CapNhat){
			//
		}
	}

	@Override
	public void keyPressed(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyReleased(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyTyped(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

}
